// custom-tab-bar/index.ts
Component({

  /**
   * 页面的初始数据
   */
  data: {
    active:0,
    tabList: [
      {
        pagePath: "/pages/home/index",
        text: "首页",
        iconPath: "/assets/tabbar/home.png",
        selectedIconPath: "/assets/tabbar/home-active.png",
        selected: true
      },
      {
        pagePath: "/pages/pay/index",
        text: "下单",
        iconPath: "/assets/tabbar/pay.png",
        selectedIconPath: "/assets/tabbar/pay-active.png",
        selected: false
      },
      {
        pagePath: "/pages/order/index",
        text: "订单",
        iconPath: "/assets/tabbar/order.png",
        selectedIconPath: "/assets/tabbar/order-active.png",
        selected: false
      },
      {
        pagePath: "/pages/my/index",
        text: "我的",
        iconPath: "/assets/tabbar/my.png",
        selectedIconPath: "/assets/tabbar/my-active.png",
        selected: false
      }
    ]
  },
  methods: {
    switchTab(event:any) {
      const index = event.currentTarget.dataset.index;
      const url = this.data.tabList[index].pagePath;
      wx.switchTab({
        url,
      })
    }
  }
})